<?php 
$bargains = $mvc->getObject(BargainsService::BARGAINS);
$error = $mvc->getObject(ContentController::ERROR);
?>
<?php if ($error!=NULL){ ?>
	<div class="unitABlock unitABlockLast">
		<div class="itemWarning">
			<ul>
				<li><?php echo $error; ?></li>
			</ul>
		</div>
	</div>
<?php }else{ ?>
<form action="my-bargains.html" method="post">
<input type="hidden" name="itemSelect" />
<ul class="viewIList">
	<li class="itemNewB"><a href="/new-bargain.html" title="New">New</a></li>
	<li class="itemDelete"><button name="delAll" onclick="return confirm('_i18n{You sure you want to delete?}');" >_i18n{Delete}</button></li>
</ul>
<h2>_i18n{My current Bargains}</h2>
<div class="unitABlock">
	<table cellpadding="0" cellspacing="0" class="viewList">
		<thead>
			<tr>
				<th class="itemChk"></th>
				<th>_i18n{Bargain-No}</th>
				<th>_i18n{Category}</th>
				<th>_i18n{Name}</th>
				<th>_i18n{Expiration Date}</th>
				<th>_i18n{Price}</th>
				<th>_i18n{Number}</th>
				<th class="itemLast">_i18n{Active}</th>
			</tr>
		</thead>
		<tbody>
<?php if (isset($bargains) && $bargains!=NULL) { ?>
<?php 	foreach ($bargains as $key=>$value){ 
			$date = date('Y-m-d')?>
<?php		if ($value[BargainsService::UNTIL_DATE]>=$date){?>
			<tr>
				<td><input type="checkbox" class="inpChk" name="chkM" value="<?php echo $value[BargainsService::HASH]?>" /></td>
				<td><a href="edit-bargain.html?id=<?php echo $value[BargainsService::HASH];?>" class="linkTr"><?php echo $value[BargainsService::ID]?></a></td>
				<td><?php echo $value[CategoryService::CAT_NAME]?></td>
				<td><?php echo $value[BargainsService::BARGAIN_NAME]?></td>
				<td><?php echo $value[BargainsService::UNTIL_DATE]?></td>
				<td><?php echo $value[BargainsService::BARGAIN_PRICE]?> &euro;</td>
				<td><?php echo $value[BargainsService::NUMBER]?></td>
				<td class="itemLast">
					<?php if (isset($value[BargainsService::STATUS])) { if($value[BargainsService::STATUS] == '0') {?>
						<a href="my-bargains.html?enabled=<?php echo $value[BargainsService::HASH];?>">_i18n{Enable}</a>
					<?php }else{ ?>
						<a href="my-bargains.html?disable=<?php echo $value[BargainsService::HASH];?>">_i18n{Disable}</a> 
					<?php }} ?>
				</td>
			</tr>
<?php 		} ?>
<?php 	} ?>
<?php } ?>
		</tbody>
	</table>
	<div class="unitBtn"></div>
</div>
<h2>_i18n{Bargains Archive}</h2>
<div class="unitABlock unitABlockLast">
	<table cellpadding="0" cellspacing="0" class="viewList">
		<thead>
			<tr>
				<th class="itemChk"></th>
				<th>_i18n{Bargain-No}</th>
				<th>_i18n{Category}</th>
				<th>_i18n{Name}</th>
				<th>_i18n{Expiration Date}</th>
				<th>_i18n{Price}</th>
				<th class="itemLast">_i18n{Buyer}</th>
			</tr>
		</thead>
		<tbody>

<?php if (isset($bargains) && $bargains!=NULL) { ?>
<?php 	foreach ($bargains as $key=>$value){ 
			$date = date('Y-m-d')?>
<?php		if ($value[BargainsService::UNTIL_DATE]<$date){?>
			<tr>
				<td><input type="checkbox" class="inpChk" name="chkM" value="<?php echo $value[BargainsService::HASH]?>" /></td>
				<td><a href="edit-bargain.html?id=<?php echo $value[BargainsService::HASH];?>" class="linkTr"><?php echo $value[BargainsService::ID]?></a></td>
				<td><?php echo $value[CategoryService::CAT_NAME]?></td>
				<td><?php echo $value[BargainsService::BARGAIN_NAME]?></td>
				<td><?php echo $value[BargainsService::UNTIL_DATE]?></td>
				<td><?php echo $value[BargainsService::BARGAIN_PRICE]?> &euro;</td>
				<td class="itemLast"><a href="#" title="Deactivate">user</a></td>
			</tr>
<?php 		} ?>
<?php 	} ?>
<?php } ?>
		</tbody>
	</table>
</div>
</form>
<?php }?>